<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Controller
 *
 * @author jonj
 */
class Controller {
    
    protected $_sView;
    protected $_sViewPath = 'view/';
    
    public function getView() {
        return $this->_sView;
    }

    
    public function load()
    {
        $this->_loadView();
    }
    
    public function show()
    {
        return $this->_getIncludeContents(_WEBSITE . '/' . $this->_sViewPath . $this->_sView);
    }
    
    protected function _loadView()
    {
        if (null == $this->_sView)
        {
            $this->_sView = 'vw_' . strtolower( substr(get_called_class(), 2) ) . '.php';
        }
    }
    
    protected function _setView($_sView) {
        $this->_sView = $_sView;
    }
    
    
    //$string = get_include_contents('somefile.php');

    protected function _getIncludeContents($filename)
    {
        if (!is_file($filename))
        {
            return false;
        }
        
        ob_start();
        include $filename;
        $contents = ob_get_contents();
        ob_end_clean();
        return $contents;
    }
}

?>
